package test;

import org.apache.commons.lang3.StringUtils;

import com.weight.common.util.ChannelUtil;
import com.weight.common.util.CommonUtils;
import com.weight.system.equmtgrp.PO.EqumtgrpInfo;

import io.netty.channel.Channel;

public class DDD {

	public static void main(String[] args) {
		
		String sendMsg = Integer.toHexString(15*4);
//  
//				 System.out.println( CommonUtils.stringToAscii(sendMsg));
//		     
//				 System.out.println(sendMsg);
//		    	sendMsg = CommonUtils.stringToAsciigHex(sendMsg);
// 
//		 System.out.println("发送：");
		
String mapStr = "2B475053494E464F3A203033362E353931323135342C3131362E393239363836360D0A0D0A4F4B0D0A";	
	 
 
System.out.println(111111111);  
 System.out.println(CommonUtils.hexStringToString(mapStr));
		 
				
			 
		 System.out.println(22222222);
//		
//		
//	    	sendMsg = CommonUtils.asciiToStringHex(sendMsg);
//		
//	    	 System.out.println(sendMsg);
		
  
	}
	/**
	 * 16进制转换成为string类型字符串
	 * @param s
	 * @return
	 */
	public static String hexStringToString(String s) {
	 if (s == null || s.equals("")) {
	  return null;
	 }
	 s = s.replace(" ", "");
	 byte[] baKeyword = new byte[s.length() / 2];
	 for (int i = 0; i < baKeyword.length; i++) {
	  try {
	   baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
	  } catch (Exception e) {
	   e.printStackTrace();
	  }
	 }
	 try {
	  s = new String(baKeyword, "UTF-8");
	  new String();
	 } catch (Exception e1) {
	  e1.printStackTrace();
	 }
	 return s;
	}
	
	
	/**
	* Convert byte[] to hex string.这里我们可以将byte转换成int，然后利用Integer.toHexString(int)来转换成16进制字符串。
	 * @param src byte[] data
	 * @return hex string
	 */
	public static String bytesToHexString(byte[] src){
	    StringBuilder stringBuilder = new StringBuilder("");
	    if (src == null || src.length <= 0) {
	        return null;
	    }
	    for (int i = 0; i < src.length; i++) {
	        int v = src[i] & 0xFF;
	        String hv = Integer.toHexString(v);
	        if (hv.length() < 2) {
	            stringBuilder.append(0);
	        }
	        stringBuilder.append(hv);
	    }
	    return stringBuilder.toString();
	}
	/**
	 * Convert hex string to byte[]
	 * @param hexString the hex string
	 * @return byte[]
	 */
	public static byte[] hexStringToBytes(String hexString){
	    if (hexString == null || hexString.equals("")) {
	        return null;
	    }
	    hexString = hexString.toUpperCase();
	    int length = hexString.length() / 2;
	    char[] hexChars = hexString.toCharArray();
	    byte[] d = new byte[length];
	    for (int i = 0; i < length; i++) {
	        int pos = i * 2;
	        d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
	    }
	    return d;
	}
	/**
	 * Convert char to byte
	 * @param c char
	 * @return byte
	 */
	 private static byte charToByte(char c){
	    return (byte) "0123456789ABCDEF".indexOf(c);
	}
 
}
